package es.springdataes.domain;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.util.Date;

@Document(indexName = "book", type = "_doc")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Book implements Serializable {
    @Id
    private String id;
    private String title;
    private String author;
//    @Field(format = DateFormat.date, type = FieldType.Date, store = true)
//    private Date postDate;
    private Long saleCnt;

    @Override
    public String toString() {
        return "Book{" +
                "id='" + id + '\'' +
                ", title='" + title + '\'' +
                ", author='" + author + '\'' +
//                ", postDate='" + postDate.toString() + '\'' +
                ", saleCnt='" + saleCnt + '\'' +
                '}';
    }
}